package gov.mogaha.ntis.cmm.mob.util;

import android.content.Context;

public class DisPlayMetricsManager {
	public static int mDisplayWidth = 320;
	private static float density = 1;
	
	public static void setDensity(Context context)
	{
		density = context.getResources().getDisplayMetrics().density;
	}
	public static float getDisplayMetricsDensity(Context context)
	{
	    return context.getResources().getDisplayMetrics().density;
	}
	public static int getPixel(int p)
	{
	    float den = density;
	    if(den != 1)
	    {
	        return (int)(p*den+0.5);
	    }
	    return p;
	}
	public static int getDip(int d)
	{
	    float den = density;
	    if(den != 1)
	    {
	        return (int)((d-0.5)/den);
	    }
	    return d;
	}
}
